﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DefaulArchitecture.Paging.Model
{
    public class PagerModel
    {
        public PagerModel(int itensPerPage, string pagerViewName)
        {
            this.ItemsPerPage = itensPerPage;
            this.pagerPartialViewName = pagerViewName;
        }

        public dynamic Filter { get; set; }
        public int Current { get; set; }
        private int countPerPage;
        private int MaxLinks { get; set; }
        public int ItemsPerPage { get { return countPerPage; } set { countPerPage = value; } }
        public int TotalItems { get; set; }
        public int TotalPages
        {
            get
            {
                if (TotalItems > 0 && ItemsPerPage > 0)
                {
                    double dblPageCount = (double)((decimal)TotalItems / Convert.ToDecimal(ItemsPerPage));
                    return (int)Math.Ceiling(dblPageCount);
                }
                else
                    return 0;
            }
        }
        private string pagerPartialViewName;
        public string PagerPartialViewName { get { return pagerPartialViewName; } }
        public string Controller { get; set; }

        public int GetStartIndexProx()
        {
            return Current + 1;
        }

        public int GetStartIndexAnt()
        {
            return Current - 1;
        }

        public int GetLastIndex()
        {
            return TotalPages;
        }

    }
}